package com.neulogistics.core.substation.infrastructure.persistence.orm.po;

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;

import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.Data;

/**
 * 缴款单表
 * @TableName tb_substation_payment
 */
@TableName(value ="tb_substation_payment", autoResultMap = true)
@Data
public class SubstationPaymentPO implements Serializable {
    /**
     * 缴款单id
     */
    @TableId(value = "payment_id")
    private Long paymentId;

    /**
     * 缴款单类型：0:收款；1:退款
     */
    @TableField(value = "payment_type")
    private Integer paymentType;

    /**
     * 所属分站id
     */
    @TableField(value = "substation_id")
    private Integer substationId;

    /**
     * 对应任务单id
     */
    @TableField(value = "task_id")
    private Long taskId;

    /**
     * 配送员 {userId，name}
     */
    @TableField(value = "courier_info", typeHandler = JacksonTypeHandler.class)
    private JSONObject courierInfo;

    /**
     * 订单客户信息，{客户id、客户名、客户电话}
     */
    @TableField(value = "custom_info", typeHandler = JacksonTypeHandler.class)
    private JSONObject customInfo;

    /**
     * 订单项，数组[{商品id、名称、数量、单价、计量单位}]
     */
    @TableField(value = "order_items", typeHandler = JacksonTypeHandler.class)
    private JSONArray orderItems;

    /**
     * 总额
     */
    @TableField(value = "payment_total")
    private Integer paymentTotal;

    /**
     * 生成时间
     */
    @TableField(value = "create_time")
    private Date createTime;

    /**
     * 是否删除
     */
    @TableField(value = "deleted")
    private Integer deleted;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        SubstationPaymentPO other = (SubstationPaymentPO) that;
        return (this.getPaymentId() == null ? other.getPaymentId() == null : this.getPaymentId().equals(other.getPaymentId()))
            && (this.getPaymentType() == null ? other.getPaymentType() == null : this.getPaymentType().equals(other.getPaymentType()))
            && (this.getSubstationId() == null ? other.getSubstationId() == null : this.getSubstationId().equals(other.getSubstationId()))
            && (this.getTaskId() == null ? other.getTaskId() == null : this.getTaskId().equals(other.getTaskId()))
            && (this.getCourierInfo() == null ? other.getCourierInfo() == null : this.getCourierInfo().equals(other.getCourierInfo()))
            && (this.getCustomInfo() == null ? other.getCustomInfo() == null : this.getCustomInfo().equals(other.getCustomInfo()))
            && (this.getOrderItems() == null ? other.getOrderItems() == null : this.getOrderItems().equals(other.getOrderItems()))
            && (this.getPaymentTotal() == null ? other.getPaymentTotal() == null : this.getPaymentTotal().equals(other.getPaymentTotal()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
            && (this.getDeleted() == null ? other.getDeleted() == null : this.getDeleted().equals(other.getDeleted()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getPaymentId() == null) ? 0 : getPaymentId().hashCode());
        result = prime * result + ((getPaymentType() == null) ? 0 : getPaymentType().hashCode());
        result = prime * result + ((getSubstationId() == null) ? 0 : getSubstationId().hashCode());
        result = prime * result + ((getTaskId() == null) ? 0 : getTaskId().hashCode());
        result = prime * result + ((getCourierInfo() == null) ? 0 : getCourierInfo().hashCode());
        result = prime * result + ((getCustomInfo() == null) ? 0 : getCustomInfo().hashCode());
        result = prime * result + ((getOrderItems() == null) ? 0 : getOrderItems().hashCode());
        result = prime * result + ((getPaymentTotal() == null) ? 0 : getPaymentTotal().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getDeleted() == null) ? 0 : getDeleted().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", paymentId=").append(paymentId);
        sb.append(", paymentType=").append(paymentType);
        sb.append(", substationId=").append(substationId);
        sb.append(", taskId=").append(taskId);
        sb.append(", courierInfo=").append(courierInfo);
        sb.append(", customInfo=").append(customInfo);
        sb.append(", orderItems=").append(orderItems);
        sb.append(", paymentTotal=").append(paymentTotal);
        sb.append(", createTime=").append(createTime);
        sb.append(", deleted=").append(deleted);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}